/* eslint-disable react-refresh/only-export-components */
import { createBrowserRouter } from "react-router-dom";
import { lazy } from "react";
import AuthRouter from "./AuthRouter";
const Login = lazy(() => import("@/pages/login"));
const Home = lazy(() => import("@/pages/home"));
const About = lazy(() => import("@/pages/about"));
const NotFindPage = lazy(() => import("@/pages/error/404"));
const Layout = lazy(() => import("@/layout"));

const router = createBrowserRouter([
  {
    path: "/",
    element: (
      <AuthRouter>
        <Layout />
      </AuthRouter>
    ),
    loader: async () => {
      localStorage.setItem("token", "loader");
      return "0";
    },
    children: [
      {
        index: true,
        element: <Home />,
      },
      {
        path: "about",
        element: <About />,
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "*",
    element: <NotFindPage />,
  },
]);

export default router;
